package com.example.demonstrate.wang.entity;

import com.example.demonstrate.wang.model.CropLocator;
import com.example.demonstrate.wang.model.Properties;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;

import java.io.Serializable;
import java.util.Map;

/**
 * @Author along
 * @Date 2024/6/11 17:22
 * @Description 档案抓拍
 */

@Data
@Document(indexName = "profile_face")
public class ProfileFace implements Serializable {

    @Id
    private String id;

    private Map<String, Integer> appData;

    private String profileId;

    @Field
    private String cameraId;

    private String cameraName;

    @Field
    private String cameraType;

    private String cameraTypeName;

    @Field
    private long capturedTime;

    private String capturedTimeInDay;

    private String capturedTimeInHour;

    private String capturedTimeInMinute;

    private String capturedTimeInMonth;

    private CropLocator cropLocator;

    private String cropUri;

    private String cropUrl;

    private String detectType;

    private String fullLocator;

    private String fullRectModel;

    private String fullUri;

    private String fullUrl;

    private String iotDeviceId;

    private String playMillis;

    private Properties properties;

    public ProfileFace(Map<String, Object> hitSource) {
        ObjectMapper mapper = new ObjectMapper();
        try {
            ProfileFace profileFace = mapper.readValue(mapper.writeValueAsString(hitSource), ProfileFace.class);
            this.id = profileFace.getId();
            this.appData = profileFace.getAppData();
            this.cameraId = profileFace.getCameraId();
            this.profileId = profileFace.getProfileId();
            this.cameraName = profileFace.getCameraName();
            this.cameraType = profileFace.getCameraType();
            this.cameraTypeName = profileFace.getCameraTypeName();
            this.capturedTime = profileFace.getCapturedTime();
            this.capturedTimeInDay = profileFace.getCapturedTimeInDay();
            this.capturedTimeInHour = profileFace.getCapturedTimeInHour();
            this.capturedTimeInMinute = profileFace.getCapturedTimeInMinute();
            this.capturedTimeInMonth = profileFace.getCapturedTimeInMonth();
            this.cropLocator = profileFace.getCropLocator();
            this.cropUri = profileFace.getCropUri();
            this.cropUrl = profileFace.getCropUrl();
            this.detectType = profileFace.getDetectType();
            this.fullLocator = profileFace.getFullLocator();
            this.fullRectModel = profileFace.getFullRectModel();
            this.fullUri = profileFace.getFullUri();
            this.fullUrl = profileFace.getFullUrl();
            this.iotDeviceId = profileFace.getIotDeviceId();
            this.playMillis = profileFace.getPlayMillis();
            this.properties = profileFace.getProperties();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
